package com.shisan.tingshu.album.api;

import com.shisan.tingshu.album.service.BaseCategoryService;
import com.shisan.tingshu.common.result.Result;
import com.shisan.tingshu.model.album.BaseAttribute;
import com.shisan.tingshu.model.album.BaseCategory3;
import com.shisan.tingshu.vo.category.CategoryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;

	@GetMapping("/getBaseCategoryList")
	@Operation(summary = "查询分类信息")
	public Result getBaseCategoryList() {

		List<CategoryVo> objectList = baseCategoryService.getBaseCategoryList();

		return Result.ok(objectList);
	}

	@GetMapping("/findAttribute/{category1Id}")
	@Operation(summary = "根据一级分类查询专辑的标签信息【属性+属性值】")
	public Result findAttribute(@PathVariable(value = "category1Id") Long category1Id) {

		List<BaseAttribute> baseAttributes = baseCategoryService.findAttribute(category1Id);

		return Result.ok(baseAttributes);
	}

	@GetMapping("/findTopBaseCategory3/{c1Id}")
	@Operation(summary = "根据一级分类id查询多个置顶的三级分类信息")
	public Result findTopBaseCategory3(@PathVariable(value = "c1Id") Long c1Id) {

		List<BaseCategory3> category3s = baseCategoryService.findTopBaseCategory3(c1Id);
		return Result.ok(category3s);
	}

	@GetMapping("/getBaseCategoryList/{c1Id}")
	@Operation(summary = "根据一级分类id查询二级分类和三级分类")
	public Result getBaseCategoryList(@PathVariable(value = "c1Id") Long c1Id) {
		CategoryVo categoryVo = baseCategoryService.getBaseCategoryListByC1Id(c1Id);
		return Result.ok(categoryVo);
	}

}

